#pragma once

#include "../windows_service/board/windows2mcu.h"

#define calibration_err (-1)

typedef struct {
  /* 注册时，SOC高的要放在数组低位，比如：
   * SOC = 25，array_index = 0
   * SOC = 15，array_index = 1
   * SOC = 5 ，array_index = 2
   * 
   * 如果是多个结构体，请确保所有的结构体SOC数据完全一致
   */
  int16 soc;
  float cell_voltage;
} discharge_soc_calibration_soc_cell_t;

typedef struct {
  int8                                  temp;
  discharge_soc_calibration_soc_cell_t *soc_cell_table;
  uint8                                 soc_cell_table_size;
} discharge_soc_calibration_t;

void discharge_soc_calibration_init(discharge_soc_calibration_t *table, uint8 table_size);
int16 discharge_soc_calibration_calibrate(int8 temp_now, int16 soc_now, float cell_min_voltage);